package com.tencent.sr.iris.basic.saas.dependency;

import com.tencent.sr.iris.basic.service.interfaces.client.CommonConfigClient;
import com.tencent.sr.iris.basic.service.interfaces.request.CommonConfigDeletRequest;
import com.tencent.sr.iris.basic.service.interfaces.request.CommonConfigInvalidRequest;
import com.tencent.sr.iris.basic.service.interfaces.request.CommonConfigQueryRequest;
import com.tencent.sr.iris.basic.service.interfaces.request.CommonConfigRequest;
import com.tencent.sr.iris.basic.service.interfaces.response.CommonConfigItemResponse;
import com.tencent.sr.iris.basic.service.interfaces.response.CommonConfigResponse;
import com.tencent.sr.rmall.common.primitive.HttpResult;
import com.tencent.sr.rmall.common.request.PaginationRequest;
import com.tencent.sr.rmall.common.response.PaginationResponse;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;

@Component
public class CommonConfigDependency {
    @Resource
    private CommonConfigClient commonConfigClient;

    public HttpResult<Boolean> save(CommonConfigRequest request) {
        return commonConfigClient.save(request);
    }


    public HttpResult<Boolean> update(CommonConfigRequest request) {
        return commonConfigClient.update(request);
    }


    public PaginationResponse<CommonConfigResponse> queryConfigs(
            PaginationRequest<CommonConfigQueryRequest> request) {
        HttpResult<PaginationResponse<CommonConfigResponse>> result = commonConfigClient.queryConfigs(request);
        if (result != null && result.isSuccess()) {
            return result.getData();
        }
        return null;
    }


    public HttpResult<Boolean> deleteConfig(CommonConfigDeletRequest request) {
        return commonConfigClient.deleteConfig(request);
    }


    public HttpResult<Boolean> invalidConfig(CommonConfigInvalidRequest request) {
        return commonConfigClient.invalidConfig(request);
    }

    public CommonConfigResponse queryConfigDetail(CommonConfigRequest request) {
        HttpResult<CommonConfigResponse> result = commonConfigClient.queryConfigDetail(request);
        if (result != null && result.isSuccess()) {
            return result.getData();
        }
        return null;
    }

    public List<CommonConfigItemResponse> queryConfigItems() {
        HttpResult<List<CommonConfigItemResponse>> result = commonConfigClient.queryConfigItems();
        if (result != null && result.isSuccess()) {
            return result.getData();
        }
        return null;
    }

}
